<?php

/**
 * Created by Reliese Model.
 */

namespace App\Models;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;

/**
 * Class ContractModel
 * 
 * @property int $id
 * @property string|null $title
 * @property int|null $product_class_id
 * @property int|null $is_able
 * @property int|null $is_upload
 * @property string|null $file_path
 * @property int|null $template_type
 * @property int|null $read_time
 * @property string|null $lang
 * @property Carbon|null $create_time
 * @property Carbon|null $update_time
 * 
 * @property ProductClass|null $product_class
 * @property Collection|Order[] $orders
 *
 * @package App\Models
 */
class ContractModel extends Model
{
	protected $table = 'contract_model';

	protected $casts = [
		'product_class_id' => 'int',
		'is_able' => 'int',
		'is_upload' => 'int',
		'template_type' => 'int',
		'read_time' => 'int'
	];

	protected $fillable = [
		'title',
		'product_class_id',
		'is_able',
		'is_upload',
		'file_path',
		'template_type',
		'read_time',
		'lang'
	];

	public function product_class()
	{
		return $this->belongsTo(ProductClass::class);
	}

	public function orders()
	{
		return $this->hasMany(Order::class, 'template_id');
	}
}
